fix(audit): เลิกรายงานว่า private repo มี branch protection ทั้งที่ตั้งไม่ได้ - #4
Merged
Merged
Conversation
…้งไม่ได้ บน private repo ของแผนฟรี GitHub ตอบ 403 พร้อม body เป็น JSON object "Upgrade to GitHub Pro or make this repository public to enable this feature." — script เดิมเอา body นั้นไปนับว่าเป็นรายการกฎ ทำให้ขึ้น "yes" ในคอลัมน์ branch protection ทั้งที่ไม่มีอะไรกันเลยสักอย่าง พลาดไปในทิศที่อันตรายที่สุด: ตารางบอกว่าปลอดภัย คนเลยไม่ไปตรวจซ้ำ เจอตอน audit org จริง — 5 จาก 8 repo รายงานผิด - แยกสถานะที่สามออกมาเป็น n/a (แผนไม่รองรับ) ต่างจาก no (ยังไม่ได้ตั้ง) เพราะสองอย่างนี้แก้คนละวิธี และ n/a ไม่ควรถูกนับว่า "ขาด" - อย่าต่อ pipe ตรงจาก gh เมื่อ gh อาจ exit non-zero — pipefail จะทำให้ pipeline ล้มก่อน grep ได้ทำงาน (พลาดตรงนี้ตอนแก้รอบแรก) - ตรวจ tree ว่ามี key "tree" จริง ไม่ใช่ error object ที่บังเอิญ parse ได้ - docs/04: เพิ่มตารางฟีเจอร์ที่ใช้ได้/ไม่ได้ตามแผนและ visibility Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dru5ECsrJrqhTfUhUvDsqw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ทำไมต้องเปลี่ยน
เจอตอน audit org จริง — 5 จาก 8 repo รายงานผิด
บน private repo ของแผนฟรี GitHub ตอบ 403 พร้อม body เป็น JSON object:
audit-repos.shเอา body นั้นไปนับตรง ๆ ว่าเป็นรายการกฎ → คอลัมน์ branch protection ขึ้นyesพลาดไปในทิศที่อันตรายที่สุด: ตารางบอกว่า repo ปลอดภัย คนเลยไม่ไปตรวจซ้ำ ทั้งที่ไม่มีอะไรกัน push ตรงเข้า main เลย
เปลี่ยนอะไร
1. เพิ่มสถานะที่สาม
n/a— "แผนไม่รองรับ" ต่างจาก "ยังไม่ได้ตั้ง" เพราะแก้คนละวิธี (no= ไปตั้งซะ ·n/a= ต้องอัปเกรดแผนหรือเปลี่ยนเป็น public) และn/aไม่ถูกนับเป็น "ขาด" ในยอดรวม2. อย่าต่อ pipe ตรงจาก
ghเมื่อมันอาจ exit non-zero — พลาดตรงนี้ตอนแก้รอบแรก:ต้องเก็บ output ก่อนแล้วค่อยตรวจ
3. ตรวจ tree ว่ามี key
treeจริง ไม่ใช่ error object ที่บังเอิญ parse เป็น JSON ได้ — บั๊กคลาสเดียวกัน ต่างกันแค่พลาดไปในทิศที่ปลอดภัยกว่า (รายงานว่าขาดทั้งที่มี)4.
docs/04— ตารางฟีเจอร์ที่ใช้ได้/ไม่ได้ตามแผนและ visibilityก่อน / หลัง
ทดสอบยังไง
ตรวจตรงกับความจริงทีละ repo ด้วย
gh api repos/O/R/rules/branches/mainแล้วผลกระทบ
ใครที่เคยรัน
audit-repos.shแล้วเห็นyesในคอลัมน์ branch protection ของ private repo — ค่านั้นผิด ให้รันใหม่